#include <bits/stdc++.h>

#define int long long

using namespace std;

void solve()
{
    int n,k;
    cin >> n >> k;

    for(int i = 1; i <= n; i ++)
    {
        int x;
        cin >> x;
        int cnt = x % (k + 1);
        cout << x + cnt * k << ' ';
    }
    cout << endl;
}

signed main()
{
    int t;
    cin >> t;
    while(t --)
    {
        solve();
    }
}